package cn.edu.scau.cmi.hekaimin.client;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.edu.scau.cmi.hekaimin.spring.domain.Student;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class SpringClient extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {
		primaryStage.setTitle("实验八: Spring");
		
		GridPane grid = new GridPane();
		grid.setPadding(new Insets(25,25,25,25));
		grid.setVgap(10);
		grid.setHgap(10);
		
		ApplicationContext act = new ClassPathXmlApplicationContext("SpringApplicationContext.xml");
		BeanFactory applicationContext = act;
		Student student = applicationContext.getBean("hekaimin", Student.class);
		
		Label label1 = new Label("姓名:");
		Label label2 = new Label("性别:");
		Label label3 = new Label("指导老师:");
		Label name = new Label(student.getName());
		Label gendar = new Label(student.getGendar());
		Label tutor = new Label(student.getTutor().getName());
		grid.add(label1, 1, 0);
		grid.add(name, 2, 0);
		grid.add(label2, 6, 0);
		grid.add(gendar, 7, 0);
		grid.add(label3, 1, 6);
		grid.add(tutor, 2, 6);
		
		
		Scene scene = new Scene(grid,400,400);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	public static void main(String[] args) {
		launch(args);

	}

}
